package com.y5neko.RadiantKnightExploit;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import org.scenicview.ScenicView;

/**
 * 方位布局
 */
public class BorderPane2 extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        AnchorPane a1=new AnchorPane();
        a1.setStyle("-fx-background-color: royalblue");
        a1.setPrefHeight(100);
        a1.setPrefWidth(100);
        AnchorPane a2=new AnchorPane();
        a2.setStyle("-fx-background-color: blueviolet");
        AnchorPane a3=new AnchorPane();
        a2.setPrefHeight(100);
        a2.setPrefWidth(100);
        a3.setStyle("-fx-background-color: blanchedalmond");
        a3.setPrefHeight(100);
        a3.setPrefWidth(100);
        AnchorPane a4=new AnchorPane();
        a4.setStyle("-fx-background-color: chartreuse");
        a4.setPrefHeight(100);
        a4.setPrefWidth(100);
        AnchorPane a5=new AnchorPane();
        a5.setStyle("-fx-background-color: aquamarine");
        a5.setPrefHeight(100);
        a5.setPrefWidth(100);
        BorderPane borderPane=new BorderPane();
        borderPane.setStyle("-fx-background-color: aqua;");
        borderPane.setTop(a1);
        borderPane.setBottom(a2);
        borderPane.setLeft(a3);
        borderPane.setCenter(a4);
        borderPane.setRight(a5);
        /**
         * 如果a1到a5都不设置宽高，则默认center优先。显示的除了内边距都是中间颜色
         * 上下部：默认撑满，即使设置宽度也无效(内边距除外)
         * 左右部：默认高度撑满(内边距除外)
         *
         * 如果上下和左右重合部分，默认上下优先
         *
         * 中部宽高填充剩余位置，设置宽高基本无效
         */

        borderPane.setPadding(new Insets(10));
        Scene scene=new Scene(borderPane);
        primaryStage.setScene(scene);
        primaryStage.setTitle("javafx");
        primaryStage.setWidth(800);
        primaryStage.setHeight(800);
        ScenicView.show(scene);
        primaryStage.show();
        /**
         *获取各个位置的组件
         */
        AnchorPane top = (AnchorPane) borderPane.getTop();
        /**
         * 如果想实现复杂布局，可以方位布局嵌套方位布局
         * 甚至嵌套其他布局，都可以
         */
    }

    public static void main(String[] args) {
        launch(args);
    }
}